package com.mohan.aop.impl;

import com.mohan.bean.RainRow;
import org.springframework.beans.factory.support.BeanDefinitionRegistry;
import org.springframework.beans.factory.support.RootBeanDefinition;
import org.springframework.context.annotation.ImportBeanDefinitionRegistrar;
import org.springframework.core.type.AnnotationMetadata;

public class MyImportBeanDefinitionRegistar implements ImportBeanDefinitionRegistrar {
    /**
     *
     * @param importingClassMetadata 当前类注解信息
     * @param registry 注册类
     */
    @Override
    public void registerBeanDefinitions(AnnotationMetadata importingClassMetadata, BeanDefinitionRegistry registry) {
        final boolean beanDefinition = registry.containsBeanDefinition("com.mohan.bean.Green");
        final boolean beanDefinition1 = registry.containsBeanDefinition("com.mohan.bean.Yellow");
        if (beanDefinition1 && beanDefinition) {
            RootBeanDefinition rootBeanDefinition = new RootBeanDefinition(RainRow.class);
            registry.registerBeanDefinition("rainRow",rootBeanDefinition);
        }
    }
}
